﻿#pragma once

#include "../MirEnvir/Envir.h"
#include "../../Shared/Enums.h"
#include "SafeZoneInfo.h"
#include "MovementInfo.h"
#include "RespawnInfo.h"
#include "NPCInfo.h"
#include "MineInfo.h"
#include <string>
#include <vector>
#include "../../stringhelper.h"

using namespace Server::MirEnvir;

namespace Server::MirDatabase
{
    class MapInfo
    {
    protected:
        static Server::MirEnvir::Envir *getEnvir();

        static Server::MirEnvir::Envir *getEditEnvir();

    public:
        int Index = 0;
        std::string FileName = std::string::Empty, Title = std::string::Empty;
        unsigned short MiniMap = 0, BigMap = 0, Music = 0;
        LightSetting Light = static_cast<LightSetting>(0);
        unsigned char MapDarkLight = 0, MineIndex = 0;

        bool NoTeleport = false, NoReconnect = false, NoRandom = false, NoEscape = false, NoRecall = false, NoDrug = false, NoPosition = false, NoFight = false, NoThrowItem = false, NoDropPlayer = false, NoDropMonster = false, NoNames = false, NoMount = false, NeedBridle = false, Fight = false, NeedHole = false, Fire = false, Lightning = false, NoTownTeleport = false, NoReincarnation = false;

        std::string NoReconnectMap = std::string::Empty;
        int FireDamage = 0, LightningDamage = 0;

        std::vector<SafeZoneInfo*> SafeZones = std::vector<SafeZoneInfo*>();
        std::vector<MovementInfo*> Movements = std::vector<MovementInfo*>();
        std::vector<RespawnInfo*> Respawns = std::vector<RespawnInfo*>();
        std::vector<NPCInfo*> NPCs = std::vector<NPCInfo*>();
        std::vector<MineZone*> MineZones = std::vector<MineZone*>();
        std::vector<Point*> ActiveCoords = std::vector<Point*>();

        MapInfo();

        MapInfo(BinaryReader *reader);

        void Save(BinaryWriter *writer);


        void CreateMap();

        void CreateSafeZone();

        void CreateRespawnInfo();

        std::string ToString();

        void CreateNPCInfo();

        void CreateMovementInfo();

        static void FromText(const std::string &text);
    };
}
